package com.zwg.tingshu.account.mapper;

import com.zwg.tingshu.model.account.UserAccount;
import com.zwg.tingshu.model.account.UserAccountDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

@Mapper
public interface UserAccountMapper extends BaseMapper<UserAccount> {

    /**
     * 账户余额扣减
     * @param userId 用户ID
     * @param amount 金额
     * @return
     */
    int checkAndDeduct(@Param("userId") Long userId, @Param("amount") BigDecimal amount);

    int add(Long userId, BigDecimal rechargeAmount);


    /**
     * 分页查询当前用户充值记录
     * @param pageInfo
     * @param userId
     * @return
     */
    Page<UserAccountDetail> getUserAccountDetailPage(Page<UserAccountDetail> pageInfo, @Param("userId") Long userId, @Param("tradeType") String tradeType);
}
